import 'package:flutter/material.dart';
import 'package:my_flutter_github/widgets/TabBarWidget.dart';
import 'package:my_flutter_github/test/TabBarPageFirst.dart';
import 'package:my_flutter_github/test/TabBarPageSecond.dart';
import 'package:my_flutter_github/test/TabBarPageThree.dart';

import 'package:my_flutter_github/MyStyle.dart';

class TabBarBottomPageWidget extends StatefulWidget {
  @override
  _TabBarBottomPageWidgetState createState() => _TabBarBottomPageWidgetState();
}

class _TabBarBottomPageWidgetState extends State<TabBarBottomPageWidget> {
  final PageController topPageControl = new PageController();
  final List<String> tab = ["动态", "趋势", "我的"];

  _renderTab() {
    List<Widget> list = new List();
    for (int i = 0; i < tab.length; i++) {
//      list.add(new FlatButton(
//          onPressed: () {
//            topPageControl.jumpTo(MediaQuery.of(context).size.width * i);
//          },
//          child: new Text(
//            tab[i],
//            maxLines: 1,
//          ),
//      ));

      list.add(new Tab(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Icon(MyIcons.MAIN_DT, size: 16.0,),
            new Text(
              tab[i],
              maxLines: 1,
//              style: MyConstants.minText,
            ),
          ],
        ),
      ));
    }
    return list;
  }

  _renderPage() {
    return [
      new TabBarPageFirst(),
      new PageBarPageSecond(),
      new TabBarPageThree(),
    ];
  }

  @override
  Widget build(BuildContext context) {
    return new TabBarWidget(
      type: TabBarWidget.TAB_BOTTOM,
      tabItems: _renderTab(),
      tabViews: _renderPage(),
      pageController: topPageControl,
      backgroundColor: Colors.black45,
      indicatorColor: Colors.red,
      title: new Text("Bottom Page Demo"),
    );
  }
}
